package pocisk;

import java.awt.geom.Point2D;

/**
 *
 * @author Maciej
 */
public class MyPoint2D extends Point2D.Double implements Cloneable { //klasa pomocnicza do operacji na punktach posiadająca pare prostych dodatkowych metod

    MyPoint2D(double x, double y) {
        super(x, y);
    }

    public static MyPoint2D NewPointMult(MyPoint2D p1, MyPoint2D p2) {
        return new MyPoint2D(p1.getX() * p2.getX(), p1.getY() * p2.getY());
    }

    public MyPoint2D PointMult(MyPoint2D p) {
        return new MyPoint2D(x * p.getX(), y * p.getY());
    }

    public static MyPoint2D NewValueMult(double a, MyPoint2D p2) {
        return new MyPoint2D(a * p2.getX(), a * p2.getY());
    }

    public MyPoint2D ValueMult(double a) {
        return new MyPoint2D(x * a, y * a);
    }

    public void ThisPointMult(MyPoint2D p) {
        x = x * p.getX();
        y = y * p.getY();
    }

    public void ThisValueMult(double a) {
        x = x * a;
        y = y * a;
    }

    public static MyPoint2D NewPointSum(MyPoint2D p1, MyPoint2D p2) {
        return new MyPoint2D(p1.getX() + p2.getX(), p1.getY() + p2.getY());
    }

    public MyPoint2D PointSum(MyPoint2D p) {
        return new MyPoint2D(x + p.getX(), y + p.getY());
    }

    public static MyPoint2D NewValueSum(double a, MyPoint2D p2) {
        return new MyPoint2D(a + p2.getX(), a + p2.getY());
    }

    public MyPoint2D ValueSum(double a) {
        return new MyPoint2D(x + a, y + a);
    }

    public void ThisPointSum(MyPoint2D p) {
        x = x + p.getX();
        y = y + p.getY();
    }

    public void ThisValueSum(double a) {
        x = x + a;
        y = y + a;
    }
    
    public static MyPoint2D NewPointSub(MyPoint2D p1, MyPoint2D p2) {
        return new MyPoint2D(p1.getX() - p2.getX(), p1.getY() - p2.getY());
    }

    public MyPoint2D PointSub(MyPoint2D p) {
        return new MyPoint2D(x - p.getX(), y - p.getY());
    }

    public static MyPoint2D NewValueSub(double a, MyPoint2D p2) {
        return new MyPoint2D(a - p2.getX(), a - p2.getY());
    }

    public MyPoint2D ValueSub(double a) {
        return new MyPoint2D(x - a, y - a);
    }

    public void ThisPointSub(MyPoint2D p) {
        x = x - p.getX();
        y = y - p.getY();
    }

    public void ThisValueSub(double a) {
        x = x - a;
        y = y - a;
    }

    public static MyPoint2D NewValueDiv(double a, MyPoint2D p2) {
        return new MyPoint2D(p2.getX()/a, p2.getY()/a);
    }

    public MyPoint2D ValueDiv(double a) {
        return new MyPoint2D(x/a, y/a);
    }

    public void ThisValueDiv(double a) {
        x = x /a;
        y = y /a;
    }

    public MyPoint2D clone(){
        return new MyPoint2D(x,y);
    }
}
